cmake_minimum_required(VERSION 3.5)
project(my_nslookup VERSION 0.1.0 LANGUAGES C)

set(CMAKE_C_STANDARD 11)

include_directories($ENV{INCLUDE})

link_directories($ENV{LIB})

add_library(lookup SHARED IMPORTED)
set_target_properties(lookup PROPERTIES
    IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/lib/lookup.dll.lib"
)

include(CTest)
enable_testing()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/bin)
add_executable(my_nslookup "src/main.c" "src/opts.c" "src/opts.h" "src/bindings.h" "src/catch.h" "src/catch.c")

add_subdirectory(lib/cargs)

target_link_libraries(my_nslookup cargs)

target_link_libraries(my_nslookup Packet)
target_link_libraries(my_nslookup wpcap)

target_link_libraries(my_nslookup lookup)
target_link_libraries(my_nslookup Ws2_32)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
set(CPACK_GENERATOR "NSIS")

include(CPack)

set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install")

install(FILES "${CMAKE_SOURCE_DIR}/bin/lookup.dll" DESTINATION bin)

install(TARGETS my_nslookup RUNTIME DESTINATION bin)